package cn.vivi.classes.service.impl;

import cn.vivi.classes.mapper.ClassesMapper;
import cn.vivi.classes.service.ClassesService;
import cn.vivi.common.entity.Classes;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class ClassesServiceImpl implements ClassesService {

    @Autowired
    private ClassesMapper classesMapper;


    @Override
    public List<Classes> findAll() {
        return classesMapper.selectList(null);
    }

    @Override
    public Classes findById(String id) {
        return classesMapper.selectById(id);
    }

    @Override
    public Page<Classes> findByPage(long current, long size) {
        return classesMapper.selectPage(new Page<>(current, size), null);
    }

    @Override
    public boolean update(Classes classes) {
        return classesMapper.updateById(classes) > 0;
    }


    @Override
    public boolean deleteClasses(String id) {
        return classesMapper.deleteById(id) > 0;
    }

    @Override
    public boolean addClasses(Classes classes) {
        return classesMapper.insert(classes) > 0;
    }

}
